﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;

namespace WCS.Infrastructure.EFCore;

/// <summary>
/// 抽奖与发券记录
/// </summary>
[Table("LotteryClaimRecord")]
[Index("ActivityId", "UserId", "RequestId", Name = "LotteryClaimRecord_Dedup_unique", IsUnique = true)]
[Index("ActivityId", "UserId", "AwardId", "Issued", "Status", "ConfigVersion", "CreationTime", Name = "idx_LotteryClaimRecord_Query")]
public partial class LotteryClaimRecord
{
    /// <summary>
    /// 抽奖记录ID
    /// </summary>
    [Key]
    [StringLength(32)]
    public string Id { get; set; } = null!;

    /// <summary>
    /// 防重入请求ID（唯一）
    /// </summary>
    [StringLength(64)]
    public string RequestId { get; set; } = null!;

    /// <summary>
    /// 活动ID
    /// </summary>
    [StringLength(32)]
    public string ActivityId { get; set; } = null!;

    /// <summary>
    /// 用户ID
    /// </summary>
    [StringLength(32)]
    public string UserId { get; set; } = null!;

    /// <summary>
    /// 奖品ID，NULL 表示“谢谢参与”
    /// </summary>
    [StringLength(32)]
    public string? AwardId { get; set; }

    /// <summary>
    /// 是否发券成功
    /// </summary>
    public bool Issued { get; set; }

    /// <summary>
    /// 结果状态：0=失败，1=成功，2=实名未完成
    /// </summary>
    public int Status { get; set; }

    /// <summary>
    /// 券实例ID（如发券成功则记录）
    /// </summary>
    [StringLength(32)]
    public string? CouponId { get; set; }

    /// <summary>
    /// 中奖对应的券模板ID（快照）
    /// </summary>
    [StringLength(32)]
    public string? TemplateId { get; set; }

    /// <summary>
    /// 文案/错误信息
    /// </summary>
    public string? Message { get; set; }

    /// <summary>
    /// 渠道/入口
    /// </summary>
    [StringLength(32)]
    public string? Channel { get; set; }

    /// <summary>
    /// 转盘命中盘位（如使用动效）
    /// </summary>
    public int? TargetSlot { get; set; }

    /// <summary>
    /// 多宫格命中格子（如使用动效）
    /// </summary>
    [StringLength(16)]
    public string? TargetCell { get; set; }

    /// <summary>
    /// 抽奖时携带的配置版本
    /// </summary>
    [StringLength(32)]
    public string? ConfigVersion { get; set; }

    /// <summary>
    /// 记录时间
    /// </summary>
    [Column(TypeName = "timestamp(6) without time zone")]
    public DateTime CreationTime { get; set; }

    /// <summary>
    /// 扩展属性（JSON文本）
    /// </summary>
    public string? ExtraProperties { get; set; }
}
